<?php 

/*
* StiPHPcms, A web Content management System made with PHP/MySQL
* JordSti : jord52@gmail.com
* Version : 0.0.2
*
* Copyright (C) 2009  jord52@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

function nextRaid($cms,$limit = 3)
{
		$now = time();
		
		$html = '';
		
		
		$dt = $cms->sql_query("SELECT raid.event,raid.type,raid.start,raid.end,raid.id FROM %prefix%raidevent raid LEFT JOIN %prefix%raidsignup signup ON(raid.id=signup.event_id) WHERE raid.end>$now GROUP BY raid.id ORDER BY start LIMIT $limit");
		
		$html .= '<table width="80%">
		<tr class="rowhead">
		<td>'.$cms->lang['raidplanner_eventname'].'</td>
		<td>-</td>
		<td>'.$cms->lang['raidplanner_start'].'</td>
		<td>'.$cms->lang['raidplanner_end'].'</td>
		</tr>';
		
		$i = 0;
		
		while($data=mysql_fetch_array($dt))
		{
			if($i==0)
			{
				$i = 1;
				$row = "row01";
			}
			else
			{
				$i = 0;
				$row = "row02";
			}
			
			$typeId = $data['type'];
			$day = date('d/m/Y',$data['start']);
			$start = date('H:i',$data['start']);
			$end = date('H:i',$data['end']);
			
			$tmp = $data['end'] - $data['start'];
			
			//echo $tmp.'<br>';
			
			$html .= '<tr class="'.$row.'">
			<td><a href="mod.php?mod=raidplanner&t=viewevent&eid='.$data['id'].'">'.$data['event'].'</a></td>
			<td>'.$day.'</td>
			<td>'.$start.'</td>
			<td>'.$end.'</td>
			</tr>';
		}
		
		$html .= '</table>';
		
		return $html;

}
?>